﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Panel.Master" Inherits="System.Web.Mvc.ViewPage<Prodma.DataAccess.Models.ViewModels.SurveyVm>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	<%=System.Configuration.ConfigurationManager.AppSettings["pageTitle"] %>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<div class="listHeader">
    <img src="../../Images/ListImages/surveylist.png" alt="" class="listHeaderIco" />
    <div class="listHeaderText">Anket Yöneticisi : <%=ViewData.Model.Name %></div>
    
    <div class="listHeaderMenuBox">
        <% Html.RenderPartial("/views/shared/userControls/acceptance.ascx",
               new Prodma.DataAccess.Models.UserControlViewModels.AcceptanceVm() { View = "survey" }); %>
    </div>
</div>

<form method="post" action="/survey/edit/">
<div class="detailContainer">
    <div class="detailSection-50pc">
        <div class="detailSectionHeader">Giriş Bilgileri</div>
        <div class="detailSectionRow">
            <div class="detailSectionRowTitle-20pc">Adı :</div>
            <div class="detailSectionRowText-80pc"><input type="text" id="name" name="name" maxlength="50" class="detailSectionControl" value='<%=ViewData.Model.Name %>' /></div>
        </div>
        <div class="detailSectionRow">
            <div class="detailSectionRowTitle-20pc">Soru :</div>
            <div class="detailSectionRowText-80pc"><input type="text" id="question" name="question" maxlength="100" class="detailSectionControl" value='<%=ViewData.Model.Question %>' /></div>
        </div>
    </div>
    <div class="detailSection-50pc">
        <div class="detailSectionHeader">Sistem Bilgileri</div>
        <div class="detailSectionRow">
            <div class="detailSectionRowTitle-20pc">Durum :</div>
            <div class="detailSectionRowText-80pc"><%=Html.DropDownList("ddlState", (SelectList)ViewData["stateList"], "Seçiniz", new { @class = "detailSectionControlCombo" })%></div>
        </div>
        <div class="detailSectionRow">
            <div class="detailSectionRowTitle-20pc">Proje :</div>
            <div class="detailSectionRowText-80pc"><%=Html.DropDownList("ddlProject", (SelectList)ViewData["projectList"], "Seçiniz", new { @class = "detailSectionControlCombo" })%></div>
        </div>
    </div>
    <div class="detailSection-50pc">
        <div class="detailSectionHeader">Seçenekler</div>
        <div class="detailSectionRow">
            <div class="detailSectionRowTitle-20pc">Seçenek :</div>
            <div class="detailSectionRowText-80pc"><input type="text" id="optionName" name="optionName" maxlength="100" class="detailSectionControl" /></div>
        </div>
        <div class="detailSectionRow">
            <div class="detailSectionRowTitle-20pc"></div>
            <div class="detailSectionRowText-80pc">
                <input type="button" id="btnAddOption" name="btnAddOption" value="Ekle" class="detailSectionControl-smallButton"  />
                <input type="button" id="btnRemoveOption" name="btnRemoveOption" value="Çıkar" class="detailSectionControl-smallButton" />
            </div>
        </div>
        <div class="detailSectionRow">
            <div class="detailSectionRowTitle-20pc">Seçenekler :</div>
            <div class="detailSectionRowText-80pc">
                <%=Html.ListBox("selectedOptions", (MultiSelectList)ViewData["selectedOptionList"], new { @class="detailSectionControl" })%>
            </div>
        </div>
    </div>
    <input type="hidden" id="id" name="id" value='<%=ViewData.Model.Id %>' />
</div>
</form>
<script type="text/javascript">
    function submitForm() {
        if (surveyValidate()) {
            document.forms[0].submit();
        }
    }
    $(function() {
    $('#btnAddOption').click(function() {
    var data1 =  escape($("#optionName").val());
             if ($('#optionName').val != "") {
                $.ajax({
                    type: "get",
                    dataType: 'html',
                    url: "/survey/addOption/?surveyId=" + $('#id').val() + "&name=" + data1,
                    success: function(data) {
                        alert('Seçenek eklendi.');
                    }
                });
                var question = document.getElementById('optionName');
                $('#selectedOptions').append('<option>' + question.value + '</option>');
                question.value = '';
                $('#optionName').focus();
            }
        });
    });
    $(function() {
        $('#btnRemoveOption').click(function() {
            if ($('#selectedOptions option').length != 0 && $("#selectedOptions :selected").val() != null) {
                $.ajax({
                    type: "get",
                    dataType: 'html',
                    url: "/survey/RemoveOption/?optionId=" + $("#selectedOptions :selected").val(),
                    success: function(data) {
                        alert('Seçenek kaldırıldı');
                    }
                });
                var questionList = document.getElementById('selectedOptions');
                questionList.remove(questionList.selectedIndex);
            }
        });
    });
</script>

</asp:Content>
